package xyz.hubery.enums;

import lombok.Data;
import lombok.Getter;

@Getter
public enum OrderDirection {

    BUY(1,"买入"),
    SELL(2,"卖出");

    private int code;
    private String desc;

    OrderDirection(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static OrderDirection getDirectionByCode(int code) {
        OrderDirection[] directions = OrderDirection.values();
        for (OrderDirection direction : directions) {
            if(direction.getCode() == code){
                return direction;
            }
        }

        return null;
    }
}
